package com.siashan.unipay4j.ali;

import com.siashan.unipay4j.ali.pay.*;
import com.siashan.unipay4j.ali.transfer.AliPayTransfer;
import com.siashan.unipay4j.ali.transfer.AliPayTransferQuery;
import com.siashan.unipay4j.core.IPayConfig;
import com.siashan.unipay4j.core.IPayFactory;
import com.siashan.unipay4j.core.pay.*;
import com.siashan.unipay4j.core.transfer.ITransfer;
import com.siashan.unipay4j.core.transfer.ITransferQuery;

/**
 * 支付宝工厂类
 *
 * @author siashan
 * @since v1.0.1
 **/
public class AliPayFactory implements IPayFactory {
    /**
     * 获取支付类
     *
     * @param tradeType   交易类型
     * @return 支付类
     */
    @Override
    public IPayment getPayment(String tradeType) {
        IPayment payment = null;
        switch (Enum.valueOf(AliTradeTypeEnum.class, tradeType)) {
            case PC:
                payment = new AliPayPc();
                break;
            case APP:
                payment = new AliPayApp();
                break;
            case WAP:
                payment = new AliPayWap();
                break;
            case MICROPAY:
                payment = new AliPayMICRO();
                break;
            case NATIVE:
                payment = new AliPayNative();
                break;
            case FACE:
                payment = new AliPayFace();
                break;
            case JASPI:
                payment = new AliPayJsApi();
                break;
            default:
                break;
        }
        return payment;
    }

    /**
     * 获取支付类
     *
     * @param tradeType  交易类型
     * @param payConfig  支付配置
     * @return 支付类
     */
    @Override
    public IPayment getPayment(String tradeType, IPayConfig payConfig) {
        IPayment payment = null;
        switch (Enum.valueOf(AliTradeTypeEnum.class, tradeType)) {
            case PC:
                payment = new AliPayPc(payConfig);
                break;
            case APP:
                payment = new AliPayApp(payConfig);
                break;
            case WAP:
                payment = new AliPayWap(payConfig);
                break;
            case MICROPAY:
                payment = new AliPayMICRO(payConfig);
                break;
            case NATIVE:
                payment = new AliPayNative(payConfig);
                break;
            case FACE:
                payment = new AliPayFace(payConfig);
                break;
            case JASPI:
                payment = new AliPayJsApi(payConfig);
                break;
            default:
                break;
        }
        return payment;
    }

    /**
     * 获取支付查询类
     *
     * @return 支付查询类
     */
    @Override
    public IQuery getQuery() {
        return new AliPayQuery();
    }

    /**
     * 获取查询类
     *
     * @param payConfig  支付配置
     * @return 支付查询类
     */
    @Override
    public IQuery getQuery(IPayConfig payConfig) {
        return new AliPayQuery(payConfig);
    }

    /**
     * 获取回调通知类
     *
     * @return 回调通知类
     */
    @Override
    public INotify getNotify() {
        return new AliPayNotify();
    }

    /**
     * 获取异步通知类
     *
     * @param payConfig  支付配置
     * @return 回调通知类
     */
    @Override
    public INotify getNotify(IPayConfig payConfig) {
        return new AliPayNotify(payConfig);
    }

    /**
     * 获取转账类
     *
     * @return 转账类
     */
    @Override
    public ITransfer getTransfer() {
        return new AliPayTransfer();
    }

    /**
     * 获取转账类
     *
     * @param payConfig  支付配置
     * @return 转账类
     */
    @Override
    public ITransfer getTransfer(IPayConfig payConfig) {
        return new AliPayTransfer(payConfig);
    }

    /**
     * 获取转账查询类
     *
     * @return 转账查询类
     */
    @Override
    public ITransferQuery getTransferQuery() {
        return new AliPayTransferQuery();
    }

    /**
     * 获取转账查询类
     *
     * @param payConfig  支付配置
     * @return 转账查询类
     */
    @Override
    public ITransferQuery getTransferQuery(IPayConfig payConfig) {
        return new AliPayTransferQuery(payConfig);
    }

    /**
     * 获取退款类
     *
     * @return 退款类
     */
    @Override
    public IRefund getRefund() {
        return new AliPayRefund();
    }

    /**
     * 获取退款类
     *
     * @param payConfig  支付配置
     * @return 退款类
     */
    @Override
    public IRefund getRefund(IPayConfig payConfig) {
        return new AliPayRefund(payConfig);
    }

    /**
     * 获取关单对象
     *
     * @since 2.0.1
     * @return 关单对象
     */
    @Override
    public IClose getClose() {
        return null;
    }

    /**
     * 获取关单对象
     *
     * @param payConfig  支付配置
     * @since 2.0.1
     * @return 关单对象
     */
    @Override
    public IClose getClose(IPayConfig payConfig) {
        return null;
    }

}
